package com.wk.wms.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wk.wms.entity.WareOrderTaskDetail;
import com.wk.wms.service.WareOrderTaskDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/wareOrderTaskDetail")
public class WareOrderTaskDetailController {

    @Autowired
    private WareOrderTaskDetailService  wareOrderTaskDetailService;

    /**
     * 查询分页数据
     */
    @GetMapping
    public IPage<WareOrderTaskDetail> findListByPage(@RequestParam(name = "pageNum", defaultValue = "1") int pageNum, @RequestParam(name = "pageSize", defaultValue = "20") int pageSize){
        return wareOrderTaskDetailService.page(new Page<>(pageNum,pageSize));
    }

    /**
     * 根据id查询
     */
    @GetMapping("{id}")
    public WareOrderTaskDetail getById(@PathVariable("id") Long id) {
        return wareOrderTaskDetailService.getById(id);
    }

    /**
     * 新增
     */
    @PostMapping
    public void insert (@RequestBody WareOrderTaskDetail wareOrderTaskDetail){
        wareOrderTaskDetailService.save(wareOrderTaskDetail);
    }

    /**
     * 删除
     */
    @DeleteMapping("{id}")
    public void deleteById(@PathVariable("id") Long id) {
        wareOrderTaskDetailService.removeById(id);
    }

    /**
     * 修改
     */
    @PutMapping
    public void updateById(@RequestBody WareOrderTaskDetail wareOrderTaskDetail){
        wareOrderTaskDetailService.updateById(wareOrderTaskDetail);
    }

}

